package wps

import (
	"github.com/zzl/go-com/com"
	"github.com/zzl/go-com/ole"
	"github.com/zzl/go-win32api/v2/win32"
	"syscall"
	"unsafe"
)

// 000244E4-0000-0000-C000-000000000046
var IID_ModelChanges = syscall.GUID{0x000244E4, 0x0000, 0x0000,
	[8]byte{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}

type ModelChanges struct {
	ole.OleClient
}

func NewModelChanges(pDisp *win32.IDispatch, addRef bool, scoped bool) *ModelChanges {
	if pDisp == nil {
		return nil
	}
	p := &ModelChanges{ole.OleClient{pDisp}}
	if addRef {
		pDisp.AddRef()
	}
	if scoped {
		com.AddToScope(p)
	}
	return p
}

func ModelChangesFromVar(v ole.Variant) *ModelChanges {
	return NewModelChanges(v.IDispatch(), false, false)
}

func (this *ModelChanges) IID() *syscall.GUID {
	return &IID_ModelChanges
}

func (this *ModelChanges) GetIDispatch(addRef bool) *win32.IDispatch {
	if addRef {
		this.AddRef()
	}
	return this.IDispatch
}

func (this *ModelChanges) QueryInterface_(riid *syscall.GUID, ppvObj unsafe.Pointer) {
	retVal, _ := this.Call(0x60000000, []interface{}{riid, ppvObj})
	_ = retVal
}

func (this *ModelChanges) AddRef() uint32 {
	retVal, _ := this.Call(0x60000001, nil)
	return retVal.UintValVal()
}

func (this *ModelChanges) Release() uint32 {
	retVal, _ := this.Call(0x60000002, nil)
	return retVal.UintValVal()
}

func (this *ModelChanges) GetTypeInfoCount(pctinfo *uint32) {
	retVal, _ := this.Call(0x60010000, []interface{}{pctinfo})
	_ = retVal
}

func (this *ModelChanges) GetTypeInfo(itinfo uint32, lcid uint32, pptinfo unsafe.Pointer) {
	retVal, _ := this.Call(0x60010001, []interface{}{itinfo, lcid, pptinfo})
	_ = retVal
}

func (this *ModelChanges) GetIDsOfNames(riid *syscall.GUID, rgszNames **int8, cNames uint32, lcid uint32, rgdispid *int32) {
	retVal, _ := this.Call(0x60010002, []interface{}{riid, rgszNames, cNames, lcid, rgdispid})
	_ = retVal
}

func (this *ModelChanges) Invoke(dispidMember int32, riid *syscall.GUID, lcid uint32, wFlags uint16, pdispparams *win32.DISPPARAMS, pvarResult *ole.Variant, pexcepinfo *win32.EXCEPINFO, puArgErr *uint32) {
	retVal, _ := this.Call(0x60010003, []interface{}{dispidMember, riid, lcid, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr})
	_ = retVal
}

func (this *ModelChanges) Application() *Application {
	retVal, _ := this.PropGet(0x00000094, nil)
	return NewApplication(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) Creator() int32 {
	retVal, _ := this.PropGet(0x00000095, nil)
	return retVal.LValVal()
}

func (this *ModelChanges) Parent() *ole.DispatchClass {
	retVal, _ := this.PropGet(0x00000096, nil)
	return ole.NewDispatchClass(retVal.IDispatch(), true)
}

func (this *ModelChanges) TablesAdded() *ModelTableNames {
	retVal, _ := this.PropGet(0x00000c49, nil)
	return NewModelTableNames(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) TablesDeleted() *ModelTableNames {
	retVal, _ := this.PropGet(0x00000c4a, nil)
	return NewModelTableNames(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) TablesModified() *ModelTableNames {
	retVal, _ := this.PropGet(0x00000c4b, nil)
	return NewModelTableNames(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) TableNamesChanged() *ModelTableNameChanges {
	retVal, _ := this.PropGet(0x00000c4c, nil)
	return NewModelTableNameChanges(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) RelationshipChange() bool {
	retVal, _ := this.PropGet(0x00000c4d, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *ModelChanges) ColumnsAdded() *ModelColumnNames {
	retVal, _ := this.PropGet(0x00000c4e, nil)
	return NewModelColumnNames(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) ColumnsDeleted() *ModelColumnNames {
	retVal, _ := this.PropGet(0x00000c4f, nil)
	return NewModelColumnNames(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) ColumnsChanged() *ModelColumnChanges {
	retVal, _ := this.PropGet(0x00000c50, nil)
	return NewModelColumnChanges(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) MeasuresAdded() *ModelMeasureNames {
	retVal, _ := this.PropGet(0x00000c51, nil)
	return NewModelMeasureNames(retVal.IDispatch(), false, true)
}

func (this *ModelChanges) UnknownChange() bool {
	retVal, _ := this.PropGet(0x00000c52, nil)
	return retVal.BoolValVal() != win32.VARIANT_FALSE
}

func (this *ModelChanges) Source() int32 {
	retVal, _ := this.PropGet(0x000000de, nil)
	return retVal.LValVal()
}
